package com.neusoft.elm01.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neusoft.elm01.entity.CommonResult;
import com.neusoft.elm01.entity.Dept;
import com.neusoft.elm01.mapper.DeptMapper;
import com.neusoft.elm01.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    DeptMapper mapper;

    @Override
    public CommonResult findAll() {
        List<Dept>lds= mapper.selectList(null);
        return new CommonResult(lds);
    }

    @Override
    public CommonResult findById(int id) {
        return new CommonResult( mapper.selectById(id));
    }


    @Override
    public CommonResult add(Dept dept) {

        return new CommonResult( mapper.insert(dept));
    }

    @Override
    public CommonResult deleteById(int id) {
        return new CommonResult( mapper.deleteById(id));
    }

    @Override
    public CommonResult update(Dept dept) {
        return new CommonResult( mapper.updateById(dept));
    }

    @Override
    public CommonResult useWrapper(QueryWrapper<Dept> wrapper) {
        return new CommonResult(mapper.selectList(wrapper));
    }
}
